[C#] RegEx search for two pattern strings and cut what's between

Posted by gsharp on Stack Overflow See other posts from Stack Overflow or by gsharp
Published on 2009-10-05T10:08:52Z Indexed on 2010/05/16 15:10 UTC
Read the original article Hit count: 171

Filed under:
|
|

I'm trying to write a little SQL Helper. I have a query like this stored in a string:

DECLARE @V1 INT

--ignore
DECLARE @V11 INT
DECLARE @V12 INT
--endignore

DECLARE @V2 INT

--ignore
SELECT * FROM SampleTable
INNER JOIN AnotherSampleTable
......
--endignore

SELECT * From Employee ORDER BY LastName

My helper method should cut everything what's between

--ignore

and

--endignore

The result string should look like:

DECLARE @V1 INT

DECLARE @V2 INT


SELECT * From Employee ORDER BY LastName

How can achieve my result with RegEx?

© Stack Overflow or respective owner

Related posts about regex

Related posts about c#